import { Component, OnInit ,Inject} from '@angular/core';
import {Router} from '@angular/router';
import { Service } from '../../server/server';
declare var $:any;

@Component({
  selector: 'app-sidebar-user',
  templateUrl: './sidebar-user.component.html'
})
export class SidebarUserComponent implements OnInit {

  right: any = {
    "root_user" : {},
    "root_roles" : {},
    "root_privilege":{},
    "roles" : {},
    "role" : {},
    "privilege":{},
    "effect":{}
 };

  constructor( public router:Router, private server:Service) { 
    //this.right = context.getRight();
    this.right = $.extend(this.right, server.getRight());
    //console.log(this.right)
  }
 
  public isActive= this.server.isActive;
  ngOnInit() {
    this.server.eventEmit.subscribe((value: any) => {
      this.isActive=value;
    });
    if(this.router.url.indexOf('/user/management')>= 0){
      this.userActive = true;
    }
    if(this.router.url.indexOf('/user/institution')>= 0){
      this.userActive = true;
    }
  }

  public userActive:any;

  ngDoCheck(){
    this.right = $.extend(this.right, this.server.getRight());
  }

  // public closeindentbutton(){
  //   if(document.body.offsetWidth < 1020){
  //     this.server.closeindentbutton();
  //   }  
  // }

  
}
